﻿using System;
using System.Linq;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;

namespace SimpleForum.Data.Models
{
    [MetadataType(typeof(ForumMetaData))]
    public partial class Forum
    {
        public int TotalPosts
        {
            get
            {
                return this.Threads.Sum(x => x.Posts.Count);
            }
        }
    }

    public class ForumMetaData
    {
        [ScaffoldColumn(false)]
        public int Id { get; set; }

        [ScaffoldColumn(false)]
        public int CreatorId { get; set; }

        [AllowHtml]
        [DataType(DataType.MultilineText)]
        public string Description { get; set; }
    }
}